package uk.co.hephistocles.blobGame;

import java.util.ArrayList;

import com.badlogic.gdx.math.Vector2;

public class Collectibles {
	private ArrayList<Collectible> itemsList;
	private Vector2 pt;
	
	public Collectibles() {
		itemsList = new ArrayList<Collectible>();
		pt = new Vector2();
	}
	
	public void add(Collectible item) {
		itemsList.add(item);
	}
	
	public boolean update(float x, float y) {
		boolean returnVal = false;
		pt.set(x,y);
		int i =0;
		for (i=0; i<itemsList.size(); i++) {
			itemsList.get(i).update();
			if (itemsList.get(i).collides(pt)) {
				itemsList.remove(i);
				returnVal = true;
			}
		}

		if (Level.multiplier != 1) {
			if (System.currentTimeMillis() - Coin.lastCoin >Coin.comboTime) {
				Level.multiplier = 1;
				Level.fontScale = Level.multiplier/Level.scoreFontRatio;
			}
		}
		return returnVal;
	}
	
	public void draw() {
		int i =0;
		for (i=0; i<itemsList.size(); i++) {
			itemsList.get(i).draw();
		}		
	}
	
	public void destroy() {
		itemsList.clear();
	}
}
